const MinStack = function() {
    // 数据栈
    this.stack = [];
    // 辅助栈
    this.minStack = [Infinity];
};

MinStack.prototype.push = function(val) {
    this.stack.push(val);
    this.minStack.push(Math.min(val, this.minStack[this.minStack.length - 1]));
};

MinStack.prototype.pop = function() {
    this.stack.pop();
    this.minStack.pop();
};

MinStack.prototype.top = function() {
    return this.stack[this.stack.length - 1];
};

MinStack.prototype.getMin = function() {
    return this.minStack[this.minStack.length - 1];
};

const minStack = new MinStack();
minStack.push(-2);
minStack.push(0);
minStack.push(-3);
const res1 = minStack.getMin();  // output: -3
console.log(res1);
minStack.pop();
const res2 = minStack.top();  // output: 0
console.log(res2);
const res3 = minStack.getMin();  // output: -2
console.log(res3);
